home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 11
/
FM Towns Free Software Collection 11.iso
/
t_os
/
tool
/
gramis
/
gramis.bas
next >
Wrap
BASIC Source File
|
1994-12-01
|
14KB
|
433 lines
10010 '--------------------------------------------------------------------
10020 '
10030 ' GRAMIS
10040 '
10050 ' Copyright (C) TeC 1994
10060 '--------------------------------------------------------------------
10070 MOUSE 0
10080 SCREEN 0: SCREEN@ 1: COLOR 7,,,4
10090 WINDOW(0,0)-(319,239): VIEW(0,0)-(319,239): CLS
10100 DEFINT A-Z
10110 RANDOMIZE DATE*100000+TIME
10120 ON ERROR GOTO *SYSERR
10130 DIM F(321,241),TIFF(76800)
10140 WIDTH 80,20: CONSOLE 0,19,2: WAIT 100
10150 *設定
10160 J=0: MOJI$="GRAMIS --[ 32768 colors 320×240 dots ]--": W=10
10170 GOSUB *PRINTER
10180 J=1: MOJI$="Copyright (C) TeC 1994": W=50
10190 GOSUB *PRINTER
10200 J=4: MOJI$="設定をします. [ ]内の数字キーを押してください.": W=50
10210 GOSUB *PRINTER
10220 J=6: MOJI$=" i) 基本色の設定 [ 1:単色 2:ランダム多色 ]": W=1
10230 GOSUB *PRINTER
10240 WHILE INKEY$><"": WEND: IN$=""
10250 WHILE IN$="": IN$=INKEY$: WEND
10260 IN=VAL(IN$)
10270 IF IN=0 OR 3<IN THEN 10240
10280 IF IN=3 THEN END
10290 IF IN=1 THEN
10300 MODE=1
10310 COLOR 4
10320 J=7: MOJI$=" 単色": W=10
10330 GOSUB *PRINTER
10340 COLOR 7
10350 MOJI$=" ↑↓で色の成分を指定後、←→で調整."
10360 J=8: W=1:GOSUB *PRINTER
10370 J=9: MOJI$=" 実行キーで決定.": W=1: GOSUB *PRINTER
10380 G=GB: R=RB: B=BB
10390 LOCATE 6,10: PRINT USING "* 緑成分 ##";G
10400 LINE(81,120)-STEP(30,8),PSET,[31,0,0],BF
10410 LOCATE 6,11: PRINT USING " 赤成分 ##";R
10420 LINE(81,132)-STEP(30,8),PSET,[0,31,0],BF
10430 LOCATE 6,12: PRINT USING " 青成分 ##";B
10440 LINE(81,144)-STEP(30,8),PSET,[0,0,31],BF
10450 LINE(71,120)-STEP(8,8),PSET,[G*8,0,0],BF
10460 LINE(71,132)-STEP(8,8),PSET,[0,R*8,0],BF
10470 LINE(71,144)-STEP(8,8),PSET,[0,0,B*8],BF
10480 IF 0<G THEN LINE(81,120)-(80+G,128),PSET,[255,0,0],BF
10490 IF 0<R THEN LINE(81,132)-(80+R,140),PSET,[0,255,0],BF
10500 IF 0<B THEN LINE(81,144)-(80+B,152),PSET,[0,0,255],BF
10510 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
10520 IRO=1': G=0: R=0: B=0********
10530 WHILE INKEY$><"": WEND: IN$=""
10540 WHILE IN$="": IN$=INKEY$: WEND
10550 IF IN$=CHR$(&H1E) THEN
10560 IRO=IRO-1: IF IRO=0 THEN IRO=1
10570 LOCATE 6,IRO+9 : PRINT "*"
10580 LOCATE 6,IRO+10: PRINT " "
10590 ENDIF
10600 IF IN$=CHR$(&H1F) THEN
10610 IRO=IRO+1: IF IRO=4 THEN IRO=3
10620 LOCATE 6,IRO+9 : PRINT "*"
10630 LOCATE 6,IRO+8 : PRINT " "
10640 ENDIF
10650 IF IN$=CHR$(&H1C) THEN
10660 IF IRO=1 THEN
10670 G=G+1: IF G=32 THEN G=31
10680 LOCATE 15,10: PRINT USING "##";G
10690 LINE(71,120)-STEP(8,8),PSET,[G*8,0,0],BF
10700 LINE(80+G,120)-STEP(0,8),PSET,[255,0,0]
10710 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
10720 ENDIF
10730 IF IRO=2 THEN
10740 R=R+1: IF R=32 THEN R=31
10750 LOCATE 15,11: PRINT USING "##";R
10760 LINE(71,132)-STEP(8,8),PSET,[0,R*8,0],BF
10770 LINE(80+R,132)-STEP(0,8),PSET,[0,255,0]
10780 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
10790 ENDIF
10800 IF IRO=3 THEN
10810 B=B+1: IF B=32 THEN B=31
10820 LOCATE 15,12: PRINT USING "##";B
10830 LINE(71,144)-STEP(8,8),PSET,[0,0,B*8],BF
10840 LINE(80+B,144)-STEP(0,8),PSET,[0,0,255]
10850 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
10860 ENDIF
10870 ENDIF
10880 IF IN$=CHR$(&H1D) THEN
10890 IF IRO=1 THEN
10900 G=G-1: IF G=-1 THEN G=0
10910 LOCATE 15,10: PRINT USING "##";G
10920 LINE(71,120)-STEP(8,8),PSET,[G*8,0,0],BF
10930 LINE(80+G+1,120)-STEP(0,8),PSET,[31,0,0]
10940 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
10950 ENDIF
10960 IF IRO=2 THEN
10970 R=R-1: IF R=-1 THEN R=0
10980 LOCATE 15,11: PRINT USING "##";R
10990 LINE(71,132)-STEP(8,8),PSET,[0,R*8,0],BF
11000 LINE(80+R+1,132)-STEP(0,8),PSET,[0,31,0]
11010 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
11020 ENDIF
11030 IF IRO=3 THEN
11040 B=B-1: IF B=-1 THEN B=0
11050 LOCATE 15,12: PRINT USING "##";B
11060 LINE(71,144)-STEP(8,8),PSET,[0,0,B*8],BF
11070 LINE(80+B+1,144)-STEP(0,8),PSET,[0,0,31]
11080 LINE(120,120)-STEP(64,32),PSET,[G*8,R*8,B*8],BF
11090 ENDIF
11100 ENDIF
11110 IF IN$><CHR$(&H0D) THEN 10530
11120 LOCATE 6,IRO+9: PRINT " "
11130 GB=G: RB=R: BB=B
11140 J=14: MOJI$="ii) グラデーションタイプの設定 [ 1:明 2:暗 ]": W=1
11150 GOSUB *PRINTER
11160 LINE(100,178)-(228,178),PSET,[127,127,127],,&H6666
11170 LINE(100,190)-(228,190),PSET,[127,127,127],,&H6666
11180 LINE(100,202)-(228,202),PSET,[127,127,127],,&H6666
11190 LINE(100,189)-(103,191),PSET,[G*8,R*8,B*8],BF
11200 LINE(100,180)-(227,188),PSET,[127,127,127],BF
11210 LINE(100,192)-(227,200),PSET,[127,127,127],BF
11220 LOCATE 8,15: PRINT "1 : 基本色⇔白"
11230 D1=31
11240 IF G<D1 THEN D1=G
11250 IF R<D1 THEN D1=R
11260 IF B<D1 THEN D1=B
11270 FOR GRAD=D1 TO 31
11280 GRADG=8*(G+FIX((GRAD-D1)*(32-G)/(32-D1)))
11290 GRADR=8*(R+FIX((GRAD-D1)*(32-R)/(32-D1)))
11300 GRADB=8*(B+FIX((GRAD-D1)*(32-B)/(32-D1)))
11310 LINE(100+4*(GRAD-D1),180)-STEP(3,8),PSET,[GRADG,GRADR,GRADB],BF
11320 NEXT
11330 LOCATE 8,16: PRINT "2 : 基本色⇔黒"
11340 D2=0
11350 IF D2<G THEN D2=G
11360 IF D2<R THEN D2=R
11370 IF D2<B THEN D2=B
11380 FOR GRAD=0 TO D2
11390 GRADG=8*(G-FIX(GRAD*(G+1)/(D2+1)))
11400 GRADR=8*(R-FIX(GRAD*(R+1)/(D2+1)))
11410 GRADB=8*(B-FIX(GRAD*(B+1)/(D2+1)))
11420 LINE(100+4*GRAD,192)-STEP(3,8),PSET,[GRADG,GRADR,GRADB],BF
11430 NEXT
11440 WHILE INKEY$><"": WEND: IN$=""
11450 WHILE IN$="": IN$=INKEY$: WEND
11460 IN=VAL(IN$)
11470 IF IN=1 THEN GRADT=1
11480 IF IN=2 THEN GRADT=2
11490 IF IN=0 OR 3<IN THEN 11440
11500 IF IN=3 THEN END
11510 IF GRADT=1 THEN
11520 COLOR 4
11530 J=17: MOJI$=" 基本色⇔白": W=100
11540 GOSUB *PRINTER
11550 COLOR 7
11560 ENDIF
11570 IF GRADT=2 THEN
11580 COLOR 4
11590 J=17: MOJI$=" 基本色⇔黒": W=100
11600 GOSUB *PRINTER
11610 COLOR 7
11620 ENDIF
11630 IN=1
11640 ENDIF
11650 IF IN=2 THEN
11660 MODE=0: GRADT=0
11670 COLOR 4
11680 J=7: MOJI$=" ランダム多色": W=100
11690 GOSUB *PRINTER
11700 COLOR 7
11710 ENDIF
11720 CLS: CONSOLE 0,20,0
11730 IF JIKKOU=1 THEN
11740 MOJI$="実行モード [ 1:消去 2:継続 3:上塗 ]"
11750 J=2: W=10: GOSUB *PRINTER
11760 WHILE INKEY$><"": WEND: IN$=""
11770 WHILE IN$="": IN$=INKEY$: WEND
11780 IN=VAL(IN$)
11790 IF IN=0 OR 4<IN THEN 11760
11800 IF IN=4 THEN END
11810 COLOR 4
11820 IF IN=1 THEN J=3: MOJI$="消去後描画": W=10: GOSUB *PRINTER
11830 IF IN=2 THEN J=3: MOJI$="描画跡継続描画": W=10: GOSUB *PRINTER
11840 IF IN=3 THEN J=3: MOJI$="描画跡上塗描画": W=10: GOSUB *PRINTER
11850 COLOR 7
11860 JMODE=IN
11870 ENDIF
11880 J=17: MOJI$="描画中、実行キーで描画を中止します.": W=10
11890 GOSUB *PRINTER
11900 J=18: MOJI$="描画に入ります. [ 1:描画 2:設定 ]": W=1
11910 GOSUB *PRINTER
11920 WHILE INKEY$><"": WEND: IN$=""
11930 WHILE IN$="": IN$=INKEY$: WEND
11940 IN=VAL(IN$)
11950 IF IN=0 OR 3<IN THEN 11920
11960 IF IN=2 THEN CLS: GOTO *設定
11970 IF IN=3 THEN END
11980 CLS
11990 GOSUB *DRAW
12000 GET@A(0,0)-(319,239),TIFF
12010 WINDOW(0,0)-(319,239)
12020 FOR I=0 TO 239
12030 LINE(0,I)-(319,I),XOR,[255,255,255]
12040 WAIT 1
12050 NEXT
12060 FOR I=239 TO 0 STEP -1
12070 LINE(0,I)-(319,I),PSET,[0,0,0]
12080 NEXT
12090 J=2: MOJI$="画像の保存 [ 1:する 2:しない ]": W=1
12100 GOSUB *PRINTER
12110 WHILE INKEY$><"": WEND: IN$=""
12120 WHILE IN$="": IN$=INKEY$: WEND
12130 IN=VAL(IN$)
12140 IF IN=0 OR 3<IN THEN 12110
12150 IF IN=3 THEN END
12160 IF IN=1 THEN
12170 COLOR 4
12180 J=3: MOJI$="保存する": W=10
12190 GOSUB *PRINTER
12200 COLOR 7
12210 FILE_NB=FILE_N
12220 IF SYSERR=64 THEN
12230 SYSERR=0
12240 CLS 5
12250 COLOR 4
12260 J=6: MOJI$="ファイル名を変更します.": W=200
12270 GOSUB *PRINTER
12280 COLOR 7
12290 J=6: MOJI$=" ": W=1
12300 GOSUB *PRINTER
12310 ENDIF
12320 FILE_N=FILE_N+1
12330 FILE_N$="TIFF"+RIGHT$(STR$(FILE_N),KLEN(STR$(FILE_N))-1)+".TIF"
12340 MOJI$=FILE_N$+" [ 1:保存 2:別の 3:取消 ]"
12350 J=5: W=1: GOSUB *PRINTER
12360 WHILE INKEY$><"": WEND: IN$=""
12370 WHILE IN$="": IN$=INKEY$: WEND
12380 IN=VAL(IN$)
12390 IF IN=0 OR 4<IN THEN 12360
12400 IF IN=4 THEN END
12410 COLOR 4
12420 IF IN=1 THEN J=6: MOJI$="保存します ": W=50: GOSUB *PRINTER
12430 IF IN=2 THEN J=6: MOJI$="別のファイル名": W=1 : GOSUB *PRINTER
12440 IF IN=3 THEN J=6: MOJI$="取消 ": W=10: GOSUB *PRINTER
12450 COLOR 7
12460 IF IN=1 THEN
12470 PUT@A(0,0)-(319,239),TIFF
12480 SAVE@ FILE_N$,(0,0)-(319,239),,1
12490 CLS 5
12500 ENDIF
12510 IF IN=2 THEN 12220
12520 IF IN=3 THEN FILE_N=FILE_NB
12530 IN=1
12540 ENDIF
12550 IF IN=2 THEN
12560 COLOR 4
12570 J=3: MOJI$="保存しない": W=10
12580 GOSUB *PRINTER
12590 COLOR 7
12600 ENDIF
12610 J=18: MOJI$="終了 [ 1:する(TownsOS) 2:しない(GRAMIS) ]": W=1
12620 GOSUB *PRINTER
12630 WHILE INKEY$><"": WEND: IN$=""
12640 WHILE IN$="": IN$=INKEY$: WEND
12650 IN=VAL(IN$)
12660 IF IN=0 OR 3<IN THEN 12630
12670 IF IN=1 OR IN=3 THEN END
12680 CLS: GOTO *設定
12690 '--------------------------------------------------------------------
12700 *DRAW
12710 WINDOW(1,1)-(320,240)
12720 PMG=0: PMR=0: PMB=0: PM=0
12730 IF GRADT=1 THEN GRAD=D1
12740 IF GRADT=2 THEN GRAD=0
12750 IF JMODE=1 OR JMODE=3 THEN
12760 ERASE F
12770 DIM F(321,241)
12780 ENDIF
12790 FOR X=0 TO 321
12800 F(X,0)=1: F(X,241)=1
12810 NEXT
12820 FOR Y=0 TO 241
12830 F(0,Y)=1: F(321,Y)=1
12840 NEXT
12850 IF JMODE=2 OR JMODE=3 THEN PUT@A(0,0)-(319,239),TIFF
12860 X=INT(RND*320)+1: Y=INT(RND*240)+1
12870 IF MODE=0 THEN
12880 G=INT(RND*32)*8: R=INT(RND*32)*8: B=INT(RND*32)*8
12890 ENDIF
12900 F(X,Y)=1
12910 WHILE INKEY$><"": WEND: IN$=""
12920 WHILE IN$=""
12930 IN$=INKEY$
12940 D=INT(RND*8)+1
12950 ON D GOSUB *D1,*D2,*D3,*D4,*D5,*D6,*D7,*D8
12960 IF DD=0 THEN
12970 N=0
12980 IF MODE=0 THEN
12990 IF PMG=0 THEN
13000 IF 240<G THEN PMG=1 ELSE G=G+8
13010 ELSE
13020 IF G<8 THEN PMG=0 ELSE G=G-8
13030 ENDIF
13040 IF PMR=0 THEN
13050 IF 240<R THEN PMR=1 ELSE R=R+8
13060 ELSE
13070 IF R<8 THEN PMR=0 ELSE R=R-8
13080 ENDIF
13090 IF PMB=0 THEN
13100 IF 240<B THEN PMB=1 ELSE B=B+8
13110 ELSE
13120 IF B<8 THEN PMB=0 ELSE B=B-8
13130 ENDIF
13140 ENDIF
13150 IF MODE=1 AND GRADT=1 THEN
13160 IF PM=0 THEN
13170 IF 30<GRAD THEN PM=1 ELSE GRAD=GRAD+1
13180 ELSE
13190 IF GRAD<D1+1 THEN PM=0 ELSE GRAD=GRAD-1
13200 ENDIF
13210 GRADG=GB+FIX((GRAD-D1)*(32-GB)/(32-D1))
13220 GRADR=RB+FIX((GRAD-D1)*(32-RB)/(32-D1))
13230 GRADB=BB+FIX((GRAD-D1)*(32-BB)/(32-D1))
13240 G=GRADG*8: R=GRADR*8: B=GRADB*8
13250 ENDIF
13260 IF MODE=1 AND GRADT=2 THEN
13270 IF PM=0 THEN
13280 IF D2-1<GRAD THEN PM=1 ELSE GRAD=GRAD+1
13290 ELSE
13300 IF GRAD<1 THEN PM=0 ELSE GRAD=GRAD-1
13310 ENDIF
13320 GRADG=GB-FIX(GRAD*(GB+1)/(D2+1))
13330 GRADR=RB-FIX(GRAD*(RB+1)/(D2+1))
13340 GRADB=BB-FIX(GRAD*(BB+1)/(D2+1))
13350 G=GRADG*8: R=GRADR*8: B=GRADB*8
13360 ENDIF
13370 PSET(X,Y),[G,R,B]
13380 ELSE
13390 N=N+1
13400 ENDIF
13410 IF 20<N THEN
13420 RANDOMIZE DATE*100000+TIME
13430 X=INT(RND*320)+1: Y=INT(RND*240)+1
13440 IF MODE=0 THEN
13450 G=INT(RND*32)*8: R=INT(RND*32)*8: B=INT(RND*32)*8
13460 ENDIF
13470 IF MODE=1 THEN
13480 G=GB*8: R=RB*8: B=BB*8
13490 ENDIF
13500 ENDIF
13510 WEND
13520 IF IN$><CHR$(&H0D) THEN 12910
13530 JIKKOU=1
13540 RETURN
13550 '--------------------------------------------------------------------
13560 *PRINTER
13570 MOJI=KLEN(MOJI$): I=0
13580 FOR N=1 TO MOJI
13590 LOCATE I,J: PRINT KMID$(MOJI$,N,1)
13600 I=I+KTYPE(MOJI$,N)+1
13610 WAIT 1
13620 NEXT
13630 WAIT W
13640 RETURN
13650 *D1
13660 X=X+1
13670 GOSUB *DD
13680 IF DD=0 THEN RETURN
13690 X=X-1
13700 RETURN
13710 *D2
13720 X=X+1: Y=Y-1
13730 GOSUB *DD
13740 IF DD=0 THEN RETURN
13750 X=X-1: Y=Y+1
13760 RETURN
13770 *D3
13780 Y=Y-1
13790 GOSUB *DD
13800 IF DD=0 THEN RETURN
13810 Y=Y+1
13820 RETURN
13830 *D4
13840 X=X-1: Y=Y-1
13850 GOSUB *DD
13860 IF DD=0 THEN RETURN
13870 X=X+1: Y=Y+1
13880 RETURN
13890 *D5
13900 X=X-1
13910 GOSUB *DD
13920 IF DD=0 THEN RETURN
13930 X=X+1
13940 RETURN
13950 *D6
13960 X=X-1: Y=Y+1
13970 GOSUB *DD
13980 IF DD=0 THEN RETURN
13990 X=X+1: Y=Y-1
14000 RETURN
14010 *D7
14020 Y=Y+1
14030 GOSUB *DD
14040 IF DD=0 THEN RETURN
14050 Y=Y-1
14060 RETURN
14070 *D8
14080 X=X+1: Y=Y+1
14090 GOSUB *DD
14100 IF DD=0 THEN RETURN
14110 X=X-1: Y=Y-1
14120 RETURN
14130 *DD
14140 DD=0
14150 IF F(X,Y)=0 THEN F(X,Y)=1 ELSE DD=1
14160 RETURN
14170 *SYSERR
14180 SYSERR=ERR
14190 IF ERR=63 THEN RESUME NEXT
14200 IF ERR=64 THEN RESUME 12220
14210 ON ERROR GOTO 0
14220 CLS
14230 PRINT "エラーが発生しました."
14240 PRINT "エラー番号 :";ERR
14250 PRINT
14260 IF ERR=7 THEN
14270 PRINT "メモリが足りないダス."
14280 PRINT
14290 ENDIF
14300 PRINT "どれかキーを押してください..."
14310 WHILE INKEY$><"" : WEND: IN$=""
14320 WHILE IN$="": IN$=INKEY$: WEND